package com.zego.wawaji.ui.store.order.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.zego.wawaji.base.data.BaseData;

import org.json.JSONObject;

/**
 * 兑换订单
 * Created by Su on 2018/1/17.
 */
public class Order extends BaseData implements Parcelable {
    private long id;                // 兑换订单ID
    private String goodsImg;        // 商品图片
    private String goodsTitle;      // 商品title
    private int goodsPrize;         // 商品价格
    private int goodsAmount;        // 商品兑换数量

    /*
    -2: 兑换被删除;
    -1:兑换已取消;
    1:兑换成功;
    2:用户请求发货;
    3:客服准备发货;
    4:已发货;
    5:用户已签收;
    6:用户已确认;
    7:用户申请退货;
    8:客服确认申请退货;
    9:完成退货;
     */
    private int orderStatus;      // 订单状态
    private long tid;              // 物流id

    @Override
    public void parseJson(String jsonStr) {
        JSONObject jsonObject = getJsonObject(jsonStr);

        this.id = jsonObject.optLong("Id");
        this.tid = jsonObject.optLong("Tid");
        this.orderStatus = jsonObject.optInt("OrderStatus");
        this.goodsImg = jsonObject.optString("GoodsImg");
        this.goodsTitle = jsonObject.optString("GoodsTitle");
        this.goodsPrize = jsonObject.optInt("GoodsWwCoinCz");
        this.goodsAmount = jsonObject.optInt("Num");
    }

    public long getId() {
        return id;
    }

    public long getTid() {
        return tid;
    }

    public int getOrderStatus() {
        return orderStatus;
    }

    public String getGoodsImg() {
        return goodsImg;
    }

    public String getGoodsTitle() {
        return goodsTitle;
    }

    public int getGoodsPrize() {
        return goodsPrize;
    }

    public int getGoodsAmount() {
        return goodsAmount;
    }

    public Order() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.id);
        dest.writeString(this.goodsImg);
        dest.writeString(this.goodsTitle);
        dest.writeInt(this.goodsPrize);
        dest.writeInt(this.goodsAmount);
        dest.writeInt(this.orderStatus);
        dest.writeLong(this.tid);
    }

    protected Order(Parcel in) {
        this.id = in.readLong();
        this.goodsImg = in.readString();
        this.goodsTitle = in.readString();
        this.goodsPrize = in.readInt();
        this.goodsAmount = in.readInt();
        this.orderStatus = in.readInt();
        this.tid = in.readLong();
    }

    public static final Creator<Order> CREATOR = new Creator<Order>() {
        @Override
        public Order createFromParcel(Parcel source) {
            return new Order(source);
        }

        @Override
        public Order[] newArray(int size) {
            return new Order[size];
        }
    };
}
